﻿using System.Diagnostics;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.Dispatcher;
//using System.Web.Http.ExceptionHandling;

namespace XRM.Security.Api
{
    public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            WebApiConfig.Register( GlobalConfiguration.Configuration );

            GlobalConfiguration.Configuration.Formatters.XmlFormatter.UseXmlSerializer = true;
            GlobalConfiguration.Configuration.Formatters.Remove( GlobalConfiguration.Configuration.Formatters.JsonFormatter );

            //GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Never;
            /*GlobalConfiguration.Configuration.Services.Replace( typeof( IHttpControllerActivator ),
                new ExceptionHandlingControllerActivator(
                    GlobalConfiguration.Configuration.Services.GetHttpControllerActivator()
                ));
            
            GlobalConfiguration.Configuration.Services.Replace( typeof( IHttpActionInvoker ), new MyApiControllerActionInvoker() );
            GlobalConfiguration.Configuration.Filters.Add( new ValidateModelAttribute() );
            */
            //GlobalConfiguration.Configuration.Services.Replace( typeof( IExceptionHandler ), new GlobalExceptionHandler() );
            //GlobalConfiguration.Configuration.MessageHandlers.Add( new WrappingHandler() );
        }
    }
}